import store from '@/store'

export default {
  inserted: (el, binding) => {
  	// el 当前绑定的元素 binding.value指令的绑定值
  	const {value} = binding
  	let roleList = store.state.sys.userInfo.roleList;
  	if (value && value instanceof Array && value.length > 0) {
  		const hasPer = roleList.some(role => {
  			return value.includes(role)
  		})
  
  		if (!hasPer) {
  			el.parentNode && el.parentNode.removeChild(el)
  		}
  	} else {
  		el.parentNode && el.parentNode.removeChild(el)
  	}
  }
}
